# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2022-2025, The OpenROAD Authors
load("//test:regression.bzl", "regression_test")

package(features = ["layering_check"])

# From CMakeLists.txt or_integration_tests(TESTS
COMPULSORY_TESTS = [
    "assign_bumps",
    "assign_bumps_two_pins",
    "bump_array_make",
    "bump_array_make_error",
    "bump_array_make_single_pitch",
    "bump_array_remove",
    "bump_array_remove_single",
    "connect_by_abutment",
    "connect_by_abutment_with_single_pinnet",
    "make_corner_sites",
    "make_io_sites",
    "make_io_sites_different_sites",
    "make_io_sites_rotations",
    "non_top_layer",
    "place_bondpad",
    "place_bondpad_stagger",
    "place_corners_avoid_bumps",
    "place_corners_avoid_overlap",
    "place_io_terminals_empty_call",
    "place_pad",
    "place_pad_hv",
    "place_pad_no_master",
    "place_pad_outsideofrow",
    "place_pad_overblockage",
    "place_pad_with_bumps",
    "place_pad_wrong_master",
    "place_pads_bumps",
    "place_pads_bumps_bump_overlap",
    "place_pads_bumps_strategy_placer_blockages",
    "place_pads_bumps_strategy",
    "place_pads_too_many",
    "place_pads_uniform",
    "place_pads_uniform_slip",
    "rdl_route",
    "rdl_route_45",
    "rdl_route_45_cost",
    "rdl_route_45_separate",
    "rdl_route_45_with_2port_bump",
    "rdl_route_45_with_oct_bump",
    "rdl_route_assignments",
    "rdl_route_assignments_overlapping_iterms",
    "rdl_route_bump_to_bump_only",
    "rdl_route_bump_via",
    "rdl_route_failed",
    "rdl_route_invalid",
    "rdl_route_max_iterations",
    "rdl_route_ports",
    "rdl_route_single_target",
    "rdl_route_via",
    "skywater130_caravel",
    "skywater130_coyote_tc",
    "skywater130_overlapping_filler",
]

# Disabled in CMakeLists.txt
MANUAL_TESTS = [
    "pad_man_tcl_check",
    "pad_readme_msgs_check",
]

# TODO: Enable once difference between bazel and ctest is resolved.
MANUAL_FOR_BAZEL_TESTS = [
    "rdl_route_single_target",
]

ALL_TESTS = COMPULSORY_TESTS + MANUAL_TESTS

filegroup(
    name = "regression_resources",
    # Dependencies could be specified more narrowly per test case,
    # but at least it is not a glob of everything and there are
    # per test glob patterns below.
    srcs = [
        "Nangate45/Nangate45.lef",
        "Nangate45/Nangate45.pdn.tcl",
        "Nangate45/Nangate45.rc",
        "Nangate45/Nangate45.rcx_rules",
        "Nangate45/Nangate45.tracks",
        "Nangate45/Nangate45.vars",
        "Nangate45/Nangate45_fast.lib",
        "Nangate45/Nangate45_lvt.lef",
        "Nangate45/Nangate45_lvt.lib",
        "Nangate45/Nangate45_slow.lib",
        "Nangate45/Nangate45_stdcell.lef",
        "Nangate45/Nangate45_tech.lef",
        "Nangate45/Nangate45_typ.lib",
        "Nangate45/fake_macros.lef",
        "Nangate45/fake_macros.lib",
        "Nangate45/fakeram45.cfg",
        "Nangate45/fakeram45_1024x32.lef",
        "Nangate45/fakeram45_1024x32.lib",
        "Nangate45/fakeram45_256x16.lef",
        "Nangate45/fakeram45_256x16.lib",
        "Nangate45/fakeram45_512x64.lef",
        "Nangate45/fakeram45_512x64.lib",
        "Nangate45/fakeram45_64x32.lef",
        "Nangate45/fakeram45_64x32.lib",
        "Nangate45/fakeram45_64x7.lef",
        "Nangate45/fakeram45_64x7.lib",
        "Nangate45/fakeram45_64x96.lef",
        "Nangate45/fakeram45_64x96.lib",
        "Nangate45/work_around_yosys/cells.v",
        "Nangate45_blackparrot/floorplan.def",
        "Nangate45_blackparrot/floorplan_flipchip.def",
        "Nangate45_blackparrot/floorplan_flipchip_2port.def",
        "Nangate45_blackparrot/floorplan_flipchip_45.def",
        "Nangate45_blackparrot/floorplan_stagger.def",
        "Nangate45_io/dummy_pads.lef",
        "Nangate45_io/dummy_pads.lib",
        "Nangate45_io/dummy_pads_m9.lef",
        "Nangate45_io/dummy_pads_stagger.lef",
        "helpers.tcl",
        "passive_tech/bumps.lef",
        "passive_tech/floorplan.def",
        "passive_tech/tech.lef",
        "sky130hd/sky130_fd_sc_hd__ff_n40C_1v95.lib",
        "sky130hd/sky130_fd_sc_hd__ss_n40C_1v40.lib",
        "sky130hd/sky130_fd_sc_hd__tt_025C_1v80.lib",
        "sky130hd/sky130_fd_sc_hd_merged.lef",
        "sky130hd/sky130hd.pdn.tcl",
        "sky130hd/sky130hd.rc",
        "sky130hd/sky130hd.rcx_rules",
        "sky130hd/sky130hd.tlef",
        "sky130hd/sky130hd.tracks",
        "sky130hd/sky130hd.vars",
        "sky130hd/sky130hd_multi_patterned.tlef",
        "sky130hd/sky130hd_std_cell.lef",
        "sky130hd/sky130hd_std_cell_vt.lef",
        "sky130hd/sky130hd_tt.lib",
        "sky130hd/sky130hd_vt.tlef",
        "sky130hd/work_around_yosys/formal_pdk.v",
        "sky130hs/sky130_fd_sc_hs__tt_025C_1v80.lib",
        "sky130hs/sky130_fd_sc_hs_merged.lef",
        "sky130hs/sky130hs.pdn.tcl",
        "sky130hs/sky130hs.rc",
        "sky130hs/sky130hs.rcx_rules",
        "sky130hs/sky130hs.tlef",
        "sky130hs/sky130hs.tracks",
        "sky130hs/sky130hs.vars",
        "sky130hs/sky130hs_ip_global.cfg",
        "sky130hs/sky130hs_std_cell.lef",
        "sky130hs/sky130hs_tt.lib",
        "skywater130_caravel/chip.v",
        "skywater130_coyote_tc/coyote_tc.v",
        "skywater130_io_ef/lef/sky130_ef_io__com_bus_slice_10um.lef",
        "skywater130_io_ef/lef/sky130_ef_io__com_bus_slice_1um.lef",
        "skywater130_io_ef/lef/sky130_ef_io__com_bus_slice_20um.lef",
        "skywater130_io_ef/lef/sky130_ef_io__com_bus_slice_5um.lef",
        "skywater130_io_ef/lef/sky130_ef_io__connect_vcchib_vccd_and_vswitch_vddio_slice_20um.lef",
        "skywater130_io_ef/lef/sky130_ef_io__corner_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__disconnect_vccd_slice_5um.lef",
        "skywater130_io_ef/lef/sky130_ef_io__disconnect_vdda_slice_5um.lef",
        "skywater130_io_ef/lef/sky130_ef_io__gpiov2_pad_wrapped.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vccd_hvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vccd_lvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vdda_hvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vdda_lvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vddio_hvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vddio_lvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vssa_hvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vssa_lvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vssd_hvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vssd_lvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vssio_hvc_pad.lef",
        "skywater130_io_ef/lef/sky130_ef_io__vssio_lvc_pad.lef",
        "skywater130_io_ef/lef/sky130_fd_io__top_xres4v2.lef",
        "skywater130_io_ef/lib/sky130_dummy_io.lib",
        "skywater130_io_fd/lef/sky130_fd_io__corner_bus_overlay.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_gpiov2.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vccd_hvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vccd_lvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vdda_hvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vdda_lvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vddio_hvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vddio_lvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vssa_hvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vssa_lvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vssd_hvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vssd_lvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vssio_hvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__overlay_vssio_lvc.lef",
        "skywater130_io_fd/lef/sky130_fd_io__top_gpio_ovtv2.lef",
        "skywater130_io_fd/lef/sky130_fd_io__top_gpiov2.lef",
        "skywater130_io_fd/lef/sky130_fd_io__top_ground_hvc_wpad.lef",
        "skywater130_io_fd/lef/sky130_fd_io__top_ground_lvc_wpad.lef",
        "skywater130_io_fd/lef/sky130_fd_io__top_power_hvc_wpad.lef",
        "skywater130_io_fd/lef/sky130_fd_io__top_power_lvc_wpad.lef",
        "skywater130_io_fd/lef/sky130_fd_io__top_xres4v2.lef",
        "skywater130_io_fd/lef/sky130io_fill.lef",
        "skywater130_io_fd/lib/sky130_dummy_io.lib",
    ],
)

[
    filegroup(
        name = test_name + "_resources",
        srcs = [":regression_resources"] + glob(
            [
                test_name + ".*",
            ],
        ),
    )
    for test_name in ALL_TESTS
]

[
    regression_test(
        name = test_name,
        data = [":" + test_name + "_resources"],
        tags = ["manual"] if test_name in MANUAL_TESTS or
                             test_name in MANUAL_FOR_BAZEL_TESTS else [],
        visibility = ["//visibility:public"],
    )
    for test_name in ALL_TESTS
]
